function[]=KDE_setting()
% KDE_setting  - setting smoothing parameters
%
%     Use only in procedure ksdesn
%
% (C) Jiri Zelinka, Jan Kolacek, Masaryk University (Czech Republic)

   
KDE_sethndl=figure(...
   'Visible','on', ...
   'Units','normalized',...
   'Name','KDE_setting', ...
   'Color',[.3 .3 .3],...
   'Tag','KDE_setting',...
   'NumberTitle','off');

setting_data=struct('K',[],'h',[],'bhandles',[]);
mf=findobj('Tag','KDE_MAIN');
main_data=get(mf,'UserData');

K=main_data.K;
h=main_data.h;
xx=main_data.xx;

setting_data.K=K;
setting_data.h=h;
setting_data.X=main_data.X;

set(KDE_sethndl,'UserData',setting_data);

lb=min(xx);
ub=max(xx);
nx=length(xx);

%
% help
%

hlpstr=char(['Firstly choose the kernel which will be used for kernel estimation. You can select a predefined or optimal kernel. ',...
	'For optimal kernel set the order and the smoothness of the kernel. The kernel will be ',...
        'of order (nu,k), where nu+k should be even. Parameter nu denote ',... 
        'order of derivative of density function. The parameter mu is the ',...
        'smoothness of this kernel, mu=-1 is for non-continuous kernel. Finally set the bandwidth h ',...
        'using some of the given methods. You can also use the algorithm for automatic choice of bandwidth and kernel.']);

% Then the editable text field
    eHndl=uicontrol( ...
	'Style','text', ...
        'Units','normalized', ...
        'Max',10, ...
        'BackgroundColor',[.9 .9 .9], ...
        'Position',[.05,.75,.9,.2], ...
        'FontSize',10, ...
        'FontUnits','normalized',...
        'HorizontalAlignment','left', ...
        'String',hlpstr);
% Then the text label

%
% kernel choice
%
    
% predefined kernels
    uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.05,.68,.2,.05], ...
        'BackgroundColor',[0.30 0.30 0.30], ...
        'ForegroundColor',[0 0 0], ...
        'String','Predefined kernels:');

kchoice=uicontrol( ...
        'Style','popup', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[0.03,.62,.2,0.05], ...
        'String',' Epanechnikov| Quartic| Gaussian| Rectangular| Triangular', ...
        'Tag','KDE_KPREDEF');

%  button OK
predef1='kdb=findobj(''Tag'',''Draw_k_button'');set(kdb,''Enable'',''on'');kch=findobj(''Tag'',''KDE_KPREDEF'');preval=get(kch,''Value'');';
predef2='switch preval, case 1,  K=K_def(''epan''); case 2, K=K_def(''quar''); case 3, K=K_def(''gaus''); case 4, K=K_def(''rect''); case 5, K=K_def(''tria'');end; ';
predef3='setfig=findobj(''Tag'',''KDE_setting'');udata=get(setfig,''UserData'');udata.K=K;set(setfig,''UserData'',udata);KDE_countbands;';
predef4='bh=udata.bhandles; nofbh=length(bh); for ii=1:nofbh, set(bh(1,ii),''Enable'',''on'');end, eyeh=findobj(''Tag'',''KDE_eyebut'');set(eyeh,''Enable'',''on'');bokh=findobj(''Tag'',''KDE_setbandOK'');set(bokh,''Enable'',''on'');';
predef5='ki=findobj(''Tag'',''KDE_kerinfo'');ks=get(kch,''String'');ks1=deblank(ks(preval,:));kis=[''Selected kernel: '',ks1,''.''];set(ki,''String'',kis);';
uicontrol( ...
        'Style','push', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[0.25,0.62,.05,0.05], ...
        'String','OK', ...
        'Callback',[predef1,predef2,predef3,predef4,predef5]);

    uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.05,.54,.2,.05], ...
        'BackgroundColor',[0.30 0.30 0.30], ...
        'ForegroundColor',[0 0 0], ...
        'String','Optimal kernel:');

% frame
    uicontrol( ...
        'Style','frame', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.03,0.47,.2,.08], ...
        'BackgroundColor',[0.50 0.50 0.50]);
% string
    uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.05,.48,.08,.05], ...
        'BackgroundColor',[0.50 0.50 0.50], ...
        'ForegroundColor',[1 1 1], ...
        'String','Set nu');

% popup menu
    nHndl=uicontrol( ...
        'Style','popup', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.15,.495,.06,.04], ...
        'Tag','KDE_KOPT_nu',...
        'String',num2str((0:6)'));


% frame
    
    uicontrol( ...
        'Style','frame', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.03,0.39,.2,.08], ...
        'BackgroundColor',[0.50 0.50 0.50]);

% string

uicontrol( ...
   	'Style','text', ...
      'Units','normalized', ...
      'FontUnits','normalized',...
      'Position',[.05,.4,.08,.05], ...
      'BackgroundColor',[0.50 0.50 0.50], ...
      'ForegroundColor',[1 1 1], ...
      'String','Set k');
% popup menu
kHndl=uicontrol( ...
        'Style','popup', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.15,.415,.06,.04], ...
        'Tag','KDE_KOPT_k',...
        'String',num2str((2:12)'));

% frame
    
    uicontrol( ...
        'Style','frame', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.03,0.31,.2,.08], ...
	'BackgroundColor',[0.50 0.50 0.50]);

% string
    uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.05,.32,.08,.05], ...
        'BackgroundColor',[0.50 0.50 0.50], ...
        'ForegroundColor',[1 1 1], ...
        'String','Set mu');
% popup menu
    mHndl=uicontrol( ...
	'Style','popup', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.15,.335,.06,.04], ...
        'Tag','KDE_KOPT_mu',...
        'Value',2,...
        'String',num2str((-1:6)'));

%  button OK
optker1='kdb=findobj(''Tag'',''Draw_k_button'');set(kdb,''Enable'',''on'');KOPT_k=findobj(''Tag'',''KDE_KOPT_k'');k=get(KOPT_k,''Value'')+1;';
optker2='KOPT_nu=findobj(''Tag'',''KDE_KOPT_nu'');nu=get(KOPT_nu,''Value'')-1;KOPT_mu=findobj(''Tag'',''KDE_KOPT_mu'');mu=get(KOPT_mu,''Value'')-2;';
optker3='if mod(k+nu,2), KDE_warning(''Parameters k and nu have to be of the same parity. Correction was made, please check the parameters again.'');if k<12 k=k+1;set(KOPT_k,''Value'',k-1);else nu=nu-1;set(KOPT_nu,''Value'',nu+1);end;end;';
optker4='if k<=nu, KDE_warning(''Parameters k has to be greater than nu. Correction was made, please check the parameters again.'');k=nu+2;set(KOPT_k,''Value'',k-1);end;';
optker5='K=K_def(''opt'',nu,k,mu);setfig=findobj(''Tag'',''KDE_setting'');udata=get(setfig,''UserData'');udata.K=K;set(setfig,''UserData'',udata);KDE_countbands;';
optker6='bh=udata.bhandles; nofbh=length(bh); for ii=1:nofbh, set(bh(1,ii),''Enable'',''on'');end, eyeh=findobj(''Tag'',''KDE_eyebut'');set(eyeh,''Enable'',''on'');bokh=findobj(''Tag'',''KDE_setbandOK'');set(bokh,''Enable'',''on'');';
optker7='ki=findobj(''Tag'',''KDE_kerinfo'');kis=[''Selected kernel: Optimal with nu='',num2str(nu),'', k='',num2str(k),'', mu='',num2str(mu),''.''];set(ki,''String'',kis);';
uicontrol( ...
        'Style','push', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[0.25,0.4,.05,0.05], ...
        'String','OK', ...
        'Callback',[optker1,optker2,optker3,optker4,optker5,optker6,optker7]);

if isempty(K), enab_but='Off'; else, enab_but='On'; end
     DKH=uicontrol('Style','push',...
          'Units','normalized', ...
          'Enable',enab_but,...
          'Tag','Draw_k_button',...
          'FontUnits','normalized',...
          'Position',[.03,.18,.2,.08], ...
          'Callback','KDE_kerdraw', ...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','Draw the kernel');

 kselstr='Selected kernel:';
 K=setting_data.K;
 if ~isempty(K)
  switch K.type
   case 'tri', kselstr=[kselstr,' triangular'];
   case 'gau', kselstr=[kselstr,' gaussian'];
   case 'opt',
    k=K.k;mu=K.mu;nu=K.nu;
    if k==2 && nu==0
     if mu==-1, kselstr=[kselstr,' rectangular'];
     elseif mu==0, kselstr=[kselstr,' Epanechnikov'];
     elseif mu==1, kselstr=[kselstr,' Quartic'];
     else kselstr=[kselstr,' Optimal with nu=',num2str(nu),', k=',num2str(k),', mu=',num2str(mu),'.'];
     end
    else kselstr=[kselstr,' Optimal with nu=',num2str(nu),', k=',num2str(k),', mu=',num2str(mu),'.'];
    end
  end
 end
    kerinfohndl=uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Tag','KDE_kerinfo',...
        'Position',[.03,.05,.25,.1], ...
        'BackgroundColor',[0.30 0.30 0.30], ...
        'ForegroundColor',[0 0 0], ...
        'String',kselstr, ...
        'HorizontalAlignment','left');

%
% bandwidth choice
%

    uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.35,.68,.2,.05], ...
        'BackgroundColor',[0.30 0.30 0.30], ...
        'ForegroundColor',[0 0 0], ...
        'String','Choose the bandwidth:');

   banchoiHndl = uibuttongroup('visible','off','Position',[.35,.3,.275,.375],'Tag','KDE_BandChoi');
% bandwidth for iterative method
if isempty(K), enab_but='Off'; else, enab_but='On'; end
   Ithndl = uicontrol('Style','Radio',...
            'Enable',enab_but,...
	    'String','Iterative',...
	    'Units','normalized', ...
	    'Tag','KDE_BCIt', ...
	    'FontUnits','normalized',...
	    'FontSize',0.45,...
	    'Position',[.01,.84,.7,.16], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on');
% bandwidth for direct-plugin method
   DPhndl = uicontrol('Style','Radio',...
            'Enable',enab_but,...
	    'String','Direct plug-in',...
	    'Units','normalized', ...
	    'Tag','KDE_BCDP', ...
	    'FontUnits','normalized',...
	    'FontSize',0.45,...
	    'Position',[.01,.7,.7,.16], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on');
% bandwidth for maximal smoothing method
   MShndl = uicontrol('Style','Radio',...
            'Enable',enab_but,...
	    'Tag','KDE_BCMS', ...
	    'String','Maximal smoothing',...
	    'Units','normalized', ...
	    'FontUnits','normalized',...
	    'FontSize',0.45,...
	    'Position',[.01,.56,.7,.16], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on');
% bandwidth for biased cross-validation method
   BChndl = uicontrol('Style','Radio',...
            'Enable',enab_but,...
	    'String','Biased cross-validation',...
	    'Tag','KDE_BCBC', ...
	    'Units','normalized', ...
	    'FontUnits','normalized',...
	    'FontSize',0.45,...
	    'Position',[.01,.42,.7,.16], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on');
% bandwidth for LS cross-validation method
   LChndl = uicontrol('Style','Radio',...
            'Enable',enab_but,...
	    'String','Least sqr. cross-validation',...
	    'Tag','KDE_BCLC', ...
	    'Units','normalized', ...
	    'FontUnits','normalized',...
	    'FontSize',0.45,...
	    'Position',[.01,.28,.7,.16], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on');
% bandwidth for reference density method
   RDhndl = uicontrol('Style','Radio',...
            'Enable',enab_but,...
	    'String','Reference density',...
	    'Tag','KDE_BCRD', ...
	    'Units','normalized', ...
	    'FontUnits','normalized',...
	    'FontSize',0.45,...
	    'Position',[.01,.14,.7,.16], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on');
% bandwidth given manually
   Manhndl = uicontrol('Style','Radio',...
            'Enable',enab_but,...
	    'String','Set maualy',...
	    'Tag','KDE_BCMan', ...
	    'Units','normalized', ...
	    'FontUnits','normalized',...
	    'FontSize',0.45,...
	    'Position',[.01,.0,.7,.16], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on');
% values of bandwidths for particular methods
   Ithndl2= uicontrol('Style','Text',...
	    'String',' ',...
	    'Units','normalized', ...
	    'Tag','KDE_BCIt_val', ...
	    'FontUnits','normalized',...
	    'Position',[.75,.82,.25,.15], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on', ...
	    'HorizontalAlignment','left');
   DPhndl2= uicontrol('Style','Text',...
	    'String',' ',...
	    'Units','normalized', ...
	    'Tag','KDE_BCDP_val', ...
	    'FontUnits','normalized',...
	    'Position',[.75,.68,.25,.15], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on', ...
	    'HorizontalAlignment','left');
   MShndl2= uicontrol('Style','Text',...
	    'Tag','KDE_BCMS_val', ...
	    'String',' ',...
	    'Units','normalized', ...
	    'FontUnits','normalized',...
	    'Position',[.75,.54,.25,.15], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on', ...
	    'HorizontalAlignment','left');
   BChndl2= uicontrol('Style','Text',...
	    'String',' ',...
	    'Tag','KDE_BCBC_val', ...
	    'Units','normalized', ...
	    'FontUnits','normalized',...
	    'Position',[.75,.40,.25,.15], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on', ...
	    'HorizontalAlignment','left');
   LChndl2= uicontrol('Style','Text',...
	    'String',' ',...
	    'Tag','KDE_BCBC_val', ...
	    'Units','normalized', ...
	    'FontUnits','normalized',...
	    'Position',[.75,.26,.25,.15], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on', ...
	    'HorizontalAlignment','left');
   RDhndl2= uicontrol('Style','Text',...
	    'String',' ',...
	    'Tag','KDE_BCRD_val', ...
	    'Units','normalized', ...
	    'FontUnits','normalized',...
	    'Position',[.75,.12,.25,.15], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on', ...
	    'HorizontalAlignment','left');
   Manhndl2 = uicontrol('Style','Edit',...
	    'String',' ',...
	    'Tag','KDE_BCMan_val', ...
	    'Units','normalized', ...
	    'FontUnits','normalized',...
            'BackgroundColor',[0.90 0.90 0.90], ...
	    'Position',[.75,.0,.25,.15], ...
	    'parent',banchoiHndl,...
	    'HandleVisibility','on', ...
	    'HorizontalAlignment','left');

  bandhandles=[Ithndl, DPhndl, MShndl, BChndl, LChndl, RDhndl,Manhndl;Ithndl2, DPhndl2, MShndl2, BChndl2, LChndl2, RDhndl2,Manhndl2];
  udata=get(KDE_sethndl,'UserData');
  udata.bhandles=bandhandles;
  set(KDE_sethndl,'UserData',udata);

  set(banchoiHndl,'SelectedObject',Ithndl);  % No selection
  set(banchoiHndl,'Visible','on');

  chband1='bc=findobj(''Tag'',''KDE_BandChoi'');bc0=get(bc,''SelectedObject'');bc1=findobj(''Tag'',''KDE_BCMan'');';
  chband2='if bc0==bc1, bcval=findobj(''Tag'',''KDE_BCMan_val'');h=eval(get(bcval,''String''));else, h=get(bc0,''UserData'');end,';
  chband3='sf=findobj(''Tag'',''KDE_setting'');udata=get(sf,''UserData'');udata.h=h;sb=findobj(''Tag'',''SelBand'');set(sb,''String'',num2str(h));set(sb,''UserData'',h);';
  chband4='mainok=findobj(''Tag'',''KDE_setMainOK'');set(mainok,''Enable'',''on'');';
  uicontrol( ...
        'Style','push', ...
        'Enable',enab_but,...
        'Tag','KDE_setbandOK', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[0.65,0.4,.05,0.05], ...
        'String','OK', ...
        'Callback',[chband1,chband2,chband3,chband4]);

  eyehndl = uicontrol('Style','push','Units','normalized', ...
            'Enable',enab_but,...
            'Tag','KDE_eyebut', ...
            'FontUnits','normalized',...
            'Position',[.35,.18,.2,.08], ...
            'Callback','KDE_eye', ...
            'BackgroundColor',[.5,0.5,0.5], ...
            'String','"Eye" method');


  selband1= uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.35,.1,.2,.05], ...
        'BackgroundColor',[0.30 0.30 0.30], ...
        'ForegroundColor',[0 0 0], ...
        'String','Selected bandwidth:', ...
	'HorizontalAlignment','left');

  if isempty(setting_data.h), selhstr='none';else selhstr=num2str(setting_data.h); end
  selband2= uicontrol( ...
        'Style','text', ...
        'Tag','SelBand', ...
        'Units','normalized', ...
        'UserData',setting_data.h, ...
        'FontUnits','normalized',...
        'Position',[.5,.1,.075,.05], ...
        'BackgroundColor',[0.30 0.30 0.30], ...
        'ForegroundColor',[0 0 0], ...
        'String',selhstr);


 Autohndl=uicontrol('Style','push','Units','normalized', ...
    'Position',[.35,.02,.27,.08], ...
    'Callback',['KDE_autopars'],...
    'BackgroundColor',[.5,0.5,0.5], ...
    'FontUnits','normalized',...
    'String','Algorithm for optimal parameters');

 if ~isempty(K)
  KDE_countbands;
 end

% selection of drawing points

    uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.725,.68,.2,.05], ...
        'BackgroundColor',[0.30 0.30 0.30], ...
        'ForegroundColor',[0 0 0], ...
        'String','Points for drawing:');

% l-band
uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.725,.59,.14,.05], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.30 0.30 0.30], ...
        'ForegroundColor',[0 0 0], ...
        'String','Lower bound');

% edit field
uicontrol( ...
        'Style','edit', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.875,.60,.075,.05], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.9 0.9 0.9], ...
        'ForegroundColor',[0 0 0], ...
        'Tag','KDE_LBOUND',...
        'String',[' ',num2str(lb)]);

% u-band
uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.725,.53,.14,.05], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.30 0.30 0.30], ...
        'ForegroundColor',[0 0 0], ...
        'String','Upper bound');
% edit field
uicontrol( ...
        'Style','edit', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.875,.54,.075,.05], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.9 0.9 0.9], ...
        'ForegroundColor',[0 0 0], ...
        'Tag','KDE_UBOUND',...
        'String',[' ',num2str(ub)]);

% nx
uicontrol( ...
        'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.725,.47,.14,.05], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.30 0.30 0.30], ...
        'ForegroundColor',[0 0 0], ...
        'String','Number of points');
% edit field
uicontrol( ...
        'Style','edit', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[.875,.48,.075,.05], ...
        'HorizontalAlignment','left',...
        'BackgroundColor',[0.9 0.9 0.9], ...
        'ForegroundColor',[0 0 0], ...
        'Tag','KDE_NX',...
        'String',[' ',num2str(nx)]);

%%  button OK
% acc1='lb_hndl=findobj(''Tag'',''KDE_LBOUND'');lb=eval(get(lb_hndl,''String''));ub_hndl=findobj(''Tag'',''KDE_UBOUND'');ub=eval(get(ub_hndl,''String''));';
% acc2='nx_hndl=findobj(''Tag'',''KDE_NX'');nx=eval(get(nx_hndl,''String''));xx=linspace(lb,ub,nx);sf=findobj(''Tag'',''KDE_setting'');udata=get(sf,''UserData'');';
% acc3='udata.xx=xx;set(sf,''UserData'',udata);';
% uicontrol( ...
%        'Style','push', ...
%        'Units','normalized', ...
%        'FontUnits','normalized',...
%        'Position',[0.9,0.4,.05,0.05], ...
%        'String','OK', ...
%        'Callback',[acc1,acc2,acc3]);

     
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% button Accept
  acc1='lb_hndl=findobj(''Tag'',''KDE_LBOUND'');lb=eval(get(lb_hndl,''String''));ub_hndl=findobj(''Tag'',''KDE_UBOUND'');ub=eval(get(ub_hndl,''String''));';
  acc2='nx_hndl=findobj(''Tag'',''KDE_NX'');nx=eval(get(nx_hndl,''String''));xx=linspace(lb,ub,nx);';
  acc3='mf=findobj(''Tag'',''KDE_MAIN'');sf=findobj(''Tag'',''KDE_setting'');selh=findobj(''Tag'',''SelBand'');mdata=get(mf,''UserData'');sdata=get(sf,''UserData'');hdata=get(selh,''UserData'');';
  acc4='LoH=mdata.LoH;nH=length(LoH);for ii=8:nH-1, set(LoH(ii),''Enable'',''On''); end; if ~isempty(mdata.f), set(LoH(nH),''Enable'',''On'');end;';
  acc5='K=sdata.K;mdata.K=K;mdata.xx=xx;h=hdata;mdata.h=h;X=mdata.X;f_est=K_dest(xx,X,h,K);mdata.f_est=f_est;set(mf,''UserData'',mdata);set(gcf,''CloseRequestFcn'',''closereq'');delete(gcf);KDE_estimdraw;';
       uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Tag','KDE_setMainOK', ...
          'Enable',enab_but,...
          'Position',[.8,.15,.14,.08], ...
          'Callback',[acc1,acc2,acc3,acc4,acc5], ...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','Accept values');

% button Cancel
       closeStr='set(gcf,''CloseRequestFcn'',''closereq'');delete(gcf);';
       uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[.8,.02,.14,.08], ...
          'Callback',closeStr, ...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','Cancel');
       
set(gcf,'CloseRequestFcn',closeStr);
     
 
        
 
set(gcf,'Position',[0.10 0.15 0.8 0.7]);

% uloz data



